package movielens;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import labeling.Labeling;
import model.MF;
import model.Predict;
import data.Data;
import file.Parser;

public class TraditionalMF {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		String dir = "D:\\MovieLens\\";
		String trainFile = "train1";
		String testFile = "test1";
		int nrat = 1000209;
		int maxuid = 6040;
		int maxiid = 3952;
		
		Parser trainParser = new Parser(dir+trainFile);
		List<Data> trainData = trainParser.getList();
		
		Parser testParser = new Parser(dir+testFile);
		List<Data> testData = testParser.getList();
		
		List<Data> wholeData = new ArrayList<Data>();
		wholeData.addAll(trainData);
		wholeData.addAll(testData);
		
		MF mf = new MF(trainData, maxuid, maxiid, 5, 0.02, 0.02);
		
		Predict normalPredict = new Predict(testData, mf);

		double epsilon = 0.2;
		Labeling trainLabel = new Labeling(trainData, mf.getAvgTrain(), mf.getUbias(), mf.getIbias(), epsilon);
		Labeling testLabel = new Labeling(testData, mf.getAvgTrain(), mf.getUbias(), mf.getIbias(), epsilon);
		
		int k = 5;
		double gamma = 0.02;
		double lambda = 0.02;
		MF pmf = new MF(trainLabel.getPos(), maxuid, maxiid, k, gamma, lambda);
		MF nmf = new MF(trainLabel.getNeg(), maxuid, maxiid, k, gamma, lambda);
		
		Predict positive = new Predict(testLabel.getPos(), pmf);
		Predict negative = new Predict(testLabel.getNeg(), nmf);
		Predict neutral = new Predict(testLabel.getNeu(), mf);
		
		//Predict positiveNormal = new Predict(testLabel.getPos(), mf);
		//Predict negativeNormal = new Predict(testLabel.getNeg(), mf);
		
		Predict whole = new Predict(testLabel.getPos(), testLabel.getNeg(), testLabel.getNeu(), mf, pmf, nmf);
	}
}
